package demo3;

import java.util.Objects;

class Person {
    public String name = "小葫芦";

    public Person(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "name=" + this.name;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name);
    }

 /*   @Override
    public boolean equals(Object obj) {
        Person per = (Person)obj;
        return per.name.equals(this.name);
    }*/
}

class Student extends Person {
    public Student(String name) {
        super(name);
    }
}

public class Test {
    public static void main(String[] args) {
        Person person1 = new Person("小洗");
        Person person2 = new Person("小洗");

        String art = "ssssss";
        Integer a = 90;

        System.out.println(person1.equals(person2));

        //System.out.println(person);
        //Object object = new Person();
    }
}

